<?php
/**
 * Created by PhpStorm.
 * User: renshan
 * Date: 16-6-30
 * Time: 下午9:54
 */

namespace FmBundle\Controller;

use OSS\OssClient;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class OssController extends Controller
{
    public function uploadVideo()
    {
        $a = new OssClient();
    }
    
    public function indexAction()
    {
        return $this->render('FmBundle:Oss:upload.html.twig');
    }

    public function uploadAction(Request $request)
    {
        $files = $request->files->all();

        dump($files);
        dump($request->files->keys());

        foreach ($files as $file) {
            $file_md5 = md5_file($file->getRealPath());
            $filename =  $file_md5.'.'. $file->getClientOriginalExtension();

            dump($file_md5);

            $file->move("/home/renshan/Dev/PHP/Fm/upload/", $filename);
        }

        return $this->render('FmBundle:Oss:upload.html.twig');

    }
}